<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('功能数设置')"/>
</head>
<style>
	.layui-form-label {
		width: 150px !important;
		text-align: left !important;
	}

	.layui-form-item .layui-input-inline {
		width: 160px !important;
		margin-bottom: 0px !important;
	}

	.layui-form-item-te {
		margin-bottom: 0px !important;
	}
</style>
<form class="layui-form layui-form-pane" action="" id="communicationform" lay-filter="communicationform">
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 5%;">
		<label class="layui-form-label" style="width: 7%">台站ID:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="stationCode" name="stationCode" autocomplete="off" readonly>
		</div>
		<label class="layui-form-label" style="width: 7%">发射机ID:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="transCode" name="transCode" autocomplete="off" readonly>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">电压门报警:</label>
		<div class="layui-input-inline">
			<select id="voltageLimitEnable" style="width: 5%" name="voltageLimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">电压门限下限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="voltageLimitMin" name="voltageLimitMin" autocomplete="off" lay-verify="required" >
		</div>
		<label class="layui-form-label" style="width: 7%">电压门限上限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="voltageLimitMax" name="voltageLimitMax" autocomplete="off" lay-verify="required" >
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">电流门限报警:</label>
		<div class="layui-input-inline">
			<select id="currentLimitEnable" style="width: 5%" name="currentLimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">电流门限下限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="currentLimitMin" name="currentLimitMin" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">电流门限上限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="currentLimitMax" name="currentLimitMax" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">温度门限一级报警:</label>
		<div class="layui-input-inline">
			<select id="temp1LimitEnable" style="width: 5%" name="temp1LimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">门限下限(一级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp1LimitMin1" name="temp1LimitMin1" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">门限上限(一级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp1LimitMax1" name="temp1LimitMax1" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">门限下限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp1LimitMin2" name="temp1LimitMin2" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">门限上限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp1LimitMax2" name="temp1LimitMax2" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">温度门限二级报警:</label>
		<div class="layui-input-inline">
			<select id="temp2LimitEnable" style="width: 5%" name="temp2LimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">温度1门限下限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp2LimitMin1" name="temp2LimitMin1" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">温度1门限上限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp2LimitMax1" name="temp2LimitMax1" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">温度1门限下限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp2LimitMin2" name="temp2LimitMin2" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">温度1门限上限(二级报警):</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="temp2LimitMax2" name="temp2LimitMax2" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">正向功率门限报警:</label>
		<div class="layui-input-inline">
			<select id="outputPwrLimitEnable" style="width: 5%" name="outputPwrLimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">正向功率门限下限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="outputPwrLimitMin" name="outputPwrLimitMin" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">正向功率门限上限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="outputPwrLimitMax" name="outputPwrLimitMax" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">反向功率门限报警:</label>
		<div class="layui-input-inline">
			<select id="refPwrLimitEnable" style="width: 5%" name="refPwrLimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">反向功率门限下限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="refPwrLimitMin" name="refPwrLimitMin" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">反向功率门限上限:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="refPwrLimitMax" name="refPwrLimitMax" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 5%;padding-top: 1%;">
		<label class="layui-form-label">驻波比报警门限报警:</label>
		<div class="layui-input-inline">
			<select id="swrLimitEnable" name="swrLimitEnable" lay-verify="required" readonly>
				<option value="0">禁止</option>
				<option value="1">有效</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">驻波比报警门限设置:</label>
		<div class="layui-input-inline" style="width: 5%">
			<input type="text" class="layui-input" id="swrLimitMax" name="swrLimitMax" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 40%;padding-top: 2%;">
		<button class="pear-btn pear-btn-primary pear-btn-sm" lay-filter="dict-data-save" lay-submit=""
				type="submit">
			<i class="layui-icon layui-icon-ok"></i>
			提交
		</button>
		<button class="pear-btn pear-btn-sm" type="reset">
			<i class="layui-icon layui-icon-refresh"></i>
			重置
		</button>
	</div>
</form>
<th:block th:include="include :: footer"/>
<script>
	layui.use(['form', 'jquery', 'popup'], function() {
		let form = layui.form;
		let $ = layui.jquery;
		let popup = layui.popup;
		let API_TRANSMITTER_PREFIX = "/api/transmitter/v1/";

		$("#stationCode").val(GetQueryString("stationCode"));
		$("#transCode").val(GetQueryString("transCode"));

		var d = {};
		var t = $('#communicationform').serializeArray();
		$.each(t, function() {
			d[this.name] = this.value;
		});
		$.ajax({
			url: API_TRANSMITTER_PREFIX + 'queryFunction',
			type: 'POST',
			contentType: 'application/json;charset=UTF-8',
			data: JSON.stringify(d),
			success: function (data) {
				if (data.code === 0) {
					$("#voltageLimitEnable").val(data.data.voltageLimitEnable);
					$("#voltageLimitMin").val(data.data.voltageLimitMin);
					$("#voltageLimitMax").val(data.data.voltageLimitMax);
					$("#currentLimitEnable").val(data.data.currentLimitEnable);
					$("#currentLimitMin").val(data.data.currentLimitMin);
					$("#currentLimitMax").val(data.data.currentLimitMax);
					$("#Temp1LimitEnable").val(data.data.temp1LimitEnable);
					$("#Temp1LimitMin1").val(data.data.temp1LimitMin1);
					$("#Temp1LimitMax1").val(data.data.temp1LimitMax1);
					$("#Temp1LimitMin2").val(data.data.temp1LimitMin2);
					$("#Temp1LimitMax2").val(data.data.temp1LimitMax2);
					$("#Temp2LimitEnable").val(data.data.temp2LimitEnable);
					$("#Temp2LimitMin1").val(data.data.temp2LimitMin1);
					$("#Temp2LimitMax1").val(data.data.temp2LimitMax1);
					$("#Temp2LimitMin2").val(data.data.temp2LimitMin2);
					$("#Temp2LimitMax2").val(data.data.temp2LimitMax2);
					$("#outputPwrLimitEnable").val(data.data.outputPwrLimitEnable);
					$("#outputPwrLimitMin").val(data.data.outputPwrLimitMin);
					$("#outputPwrLimitMax").val(data.data.outputPwrLimitMax);
					$("#refPwrLimitEnable").val(data.data.refPwrLimitEnable);
					$("#refPwrLimitMin").val(data.data.refPwrLimitMin);
					$("#refPwrLimitMax").val(data.data.refPwrLimitMax);
					$("#swrLimitEnable").val(data.data.swrLimitEnable);
					$("#swrLimitMax").val(data.data.swrLimitMax);
					$("#sendTime").val(data.data.sendTime);
					$("#transIp").val(data.data.transIp);
					$("#transHttpsPort").val(data.data.transHttpsPort);
					$("#transHttpPort").val(data.data.transHttpPort);
					$("#stationCode").val(data.data.stationCode);
					$("#transCode").val(data.data.transCode);
					popup.success("获取功能参数成功");
				} else {
					popup.failure(data.msg);
				}
			},
			error: function () {
				popup.failure("获取发射机运行参数接口访问失败!")
			}
		});

		form.on('submit(dict-data-save)', function(data) {
			$.ajax({
				url: API_TRANSMITTER_PREFIX + "setFunction",
				data: JSON.stringify(data.field),
				dataType: 'json',
				contentType: 'application/json',
				type: 'post',
				success: function(result) {
					if (result.success) {
						layer.msg(result.msg, {
							icon: 1,
							time: 1000
						}, function() {
						});
					} else {
						layer.msg(result.msg, {
							icon: 2,
							time: 1000
						});
					}
				}
			})
			return false;
		});
		function GetQueryString(name) {
			const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			const r = window.location.search.substr(1).match(reg);
			if (r != null) return unescape(r[2]);
			return null;
		}
	})
</script>
</html>